package com.yboot.starter.mybatis.core.base.query;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.yboot.starter.api.core.annotation.QueryIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import java.io.Serializable;
import java.util.List;

/**
 * 分页
 */
@Data
public class PageQuery implements Serializable {
    /**
     * 默认页码：1
     */
    private static final int DEFAULT_PAGE = 1;

    /**
     * 默认每页条数：10
     */
    private static final int DEFAULT_SIZE = 10;

    /**
     * 页码
     */
    @Min(value = 1, message = "页码最小值为 {value}")
    @QueryIgnore
    @Schema(description="页码",  example = "1")
    private Integer page = DEFAULT_PAGE;

    /**
     * 每页条数
     */
    @Range(min = 1, max = 1000, message = "每页条数（取值范围 {min}-{max}）")
    @QueryIgnore
    @Schema(description="每页条数",  example = "10")
    private Integer size = DEFAULT_SIZE;

    /**
     * 排序
     */
    @QueryIgnore
    private List<OrderItem> orders;

}